package com.kstech.ks_gaz01.realTime

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import com.kstech.ks_gaz01.data.DebugDataBean
import com.kstech.ks_gaz01.databinding.LayoutItemSimulationPart1Binding

class SimulationAdapter : BaseQuickAdapter<DebugDataBean.Item, SimulationAdapter.VH>() {

    // 自定义ViewHolder类
    class VH(
        parent: ViewGroup,
        val binding: LayoutItemSimulationPart1Binding = LayoutItemSimulationPart1Binding.inflate(
            LayoutInflater.from(parent.context), parent, false
        ),
    ) : RecyclerView.ViewHolder(binding.root)

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
        // 返回一个 ViewHolder
        return VH(parent)
    }


    override fun onBindViewHolder(holder: VH, position: Int, item: DebugDataBean.Item?) {
        if (item!!.revData.toInt() - 1 < 0) {
            holder.binding.value.text = DebugDataBean.zt_array[0]
        } else {
            holder.binding.value.text = DebugDataBean.zt_array[item!!.revData.toInt() - 1]
        }
        holder.binding.t.text = item.para1

        holder.binding.checkBox.isSelected = item.isCheckBox
    }
}